{include file="Public:header" /}
<style>
	.pagination a{
	    background-color: #f4f4f4;
	    z-index: 2;
		border:1px solid #000;
	    border-color: rgb(221, 221, 221);
		padding: 4px 10px;
		margin:0px 3px;
		border-radius:10%;
	}
</style>
<body class="gray-bg">
	<div class="wrapper wrapper-content animated fadeInRight">
		<div class="row">
			<div class="col-sm-12">
				<div class="ibox float-e-margins">
					<div class="ibox-title">
						<h5>规则列表</h5>
						<div class="ibox-tools">
						<a href="{:U('Ruleprize/ruleList')}" class="btn btn-primary">刷新</a>
						</div>
					</div>
					<div class="ibox-content">
						<div class="row">
							<!-- <a href="__URL__/addRule" class="btn btn-primary">
								<span class="fa fa-plus"></span>
								添加新规则
							</a> -->
							<div class="col-sm-3  pull-right">
									<form action="__URL__/ruleList" method="post">
		                                <div class="input-group">
			                                    <input type="text" name="rule_name" placeholder="请输入规则名称" class="input-sm form-control"> 
			                                    <span class="input-group-btn">
			                                      <button type="submit" class="btn btn-sm btn-primary"> 搜索</button>
			                                    </span>
		                                </div>
	                                 </form>
	                            </div>
						</div>
						<br />
						<div class="table-responsive">
							<table class="table table-bordered table-hover"
								id="categoryTable">
								<thead>
									<tr style="background: #f9f9f9;">
									<th height="40">规则名称</th>
									<!--<th>活动项目</th>-->
									<!--<th>循环天数</th>-->
									<!--<th>该活动每天最多可抽奖次数</th>-->
									<th>用户每天最多抽奖机会</th>
									<!--<th>实物抽中次数</th>-->
									<!-- <th>开始时间</th>
									<th>结束时间</th> -->
									<th>状态</th>
									<th>操作</th>
									</tr>
								</thead>
								<tbody>
									{foreach name="rule" item="rule"}
									<tr>
									<td>{$rule['rule_name']}</td>
									<!--<td>{$rule['a_id']}</td>-->
									<!--<td>{$rule['loop_day']}</td>-->
									<!--<td>{$rule['day_num']}</td>-->
									<td>{$rule['most_num']}</td>
									<!--<td>{$rule['matter_num']}</td>-->
										<td>
											{switch name="rule['status']"}
												{case value="1"}启用{/case}
												{case value="0"}停用{/case}
											    {default /}停用
											{/switch}
										</td>
									<!-- <td>{$rule['statr_time']|date="Y-m-d H:i:s",###}</td>
									<td>{$rule['end_time']|date="Y-m-d H:i:s",###}</td> -->
										<td class="center">
											<div class="dropdown">
												<button class="btn btn-primary dropdown-toggle"
													type="button" id="dropdownMenu1" data-toggle="dropdown"
													aria-haspopup="true" aria-expanded="true">
													操作
													<span class="caret"></span>
												</button>
												<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
													<li>
														<a role="button" class="btn btn-primary"
															style="margin-bottom: 0px;" rule_id="{$rule['r_id']}"
															href="__URL__/updateRule?rule_id={$rule['r_id']}">
															<span class="fa fa-edit"></span>
															修改规则
														</a>
													</li>
													<!--<li>
														<a role="button" class="btn btn-danger"
															style="margin-bottom: 0px;"
															onclick="deleteCategory(this,{$rule['r_id']})" href="javascript:void(0);">
															<span class="fa fa-trash-o"></span>
															删除
														</a>
													</li>-->
												</ul>
											</div>
										</td>
									</tr>
									{/foreach}
								</tbody>
							</table>
							<div class="col-sm-12 text-center">
								<nav aria-label="Page navigation">
								  <ul class="pagination">
								    {$page}
								  </ul>
								</nav>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	{include file="Public:footer" /}
</body>
</html>
<script>
    //删除
    function deleteCategory(obj,r_id){
        layer.confirm('确定要删除数据吗',{btn:['确认','取消'], icon:3, closeBtn: 2 },function(index){
            $.ajax({
                url : '__URL__/deleteRule',
                data : {'r_id':r_id},
                type : 'get',
                dataType : 'json',
                async : false,   //取消同步，执行完之后再往下执行
                success : function(data){
                    if(data.status == 1){
                        layer.msg(''+data.message+'',{icon:2,time:1000});
                        $(obj).parent('li').parent('ul').parent('div').parent('td').parent('tr').remove();
                    }else if(data.status == 2){
                        layer.msg(''+data.message+'',{icon:1,time:1000});
                    }
                }
            });
        });
    }
</script>